#ifndef __RISCV_H_
#define __RISCV_H_

#define QEMU_KERN_START 0x80200000UL
#define QEMU_MAX_ADDR 0x88000000UL
#define K210_KERN_START 0x80020000UL
#define K210_MAX_ADDR 0x80600000UL

#define SSTATUS_SIE (1L << 1)
#define SSTATUS_SPP (1L << 8)
#define SSTATUS_SPIE (1L << 5)

#define SIE_TIMER (1L << 5)

#define S_TIMER 5
#define U_ENV_CALL 8


// must be assigned to a variable
#define csrr(csr, val) asm volatile ("csrr %0,"#csr:"=r"(val))

// val must be stored in a variable uint64
#define csrw(csr, val) asm volatile ("csrw "#csr", %0" ::"r"(val))

#endif
